package day02;

import java.util.Random;
import java.util.Scanner;

import org.junit.Test;

public class ForTest {
	@Test
	public void test2() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入成绩：");
		int score = scanner.nextInt();
		if(score >=90 && score <=100) {
			System.out.println("优秀");
		}else if(score >=80 && score <90) {
			System.out.println("良好");
		}else if(score >=70 && score <80) {
			System.out.println("一般");
		}else if(score >=60 && score <70) {
			System.out.println("及格");
		}else {
			System.out.println("不及格");
		}
	}
	@Test
	public void test8() {
		Scanner scanner = new Scanner(System.in);
		// Random().nextInt(300)   		0~299
		// Random().nextInt(300)+1      1~300
		int random = new Random().nextInt(300) + 1;
		System.out.println(random);
		while (true) {
			System.out.println("猜吧！");
			int num = scanner.nextInt();
			if (num > random) {
				System.out.println("太大了");
			} else if (num < random) {
				System.out.println("太小了");
			} else {
				System.out.println("猜对了");
				// 退出while循环
				break;
			}
		}
	}
	@Test
	public void test03() {
		for (int  i = 1; i <= 9; i++) {
			for (int j = 1; j <= i; j++) {
				System.out.print(i + "*" + j + "=" + (i * j) + "\t");
			}
		System.out.println();
	}
 }
	@Test
	public void test04() {
		for(int i = 1; i <= 5; i++) {
			for(int j = 1; j <= i; j++) {
			System.out.print(j + "*" + i + "=" + (i * j) + "\t");
			}
			System.out.println();
		}
		
	}
	@Test
	public void test05() {
		int count = 0;
		for(int i = 1; i <= 200; i++) {
			if(i % 7 == 0) {
				System.out.println(i);
				count++;
				System.out.println("count: " + count);
			}
		}
		System.out.println(count);
	}
	@Test
	public void test06() {
		int num = 2;
		switch (num) {
		case 1:
		    System.out.println("1");
		break;
		case 2:
			System.out.println("2");
		break;
		case 3:
			System.out.println("3");
		break;
		default:
			break;
		}
	}
	
	@Test
	public void test07() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入月份：");
		int month = scanner.nextInt();
		switch(month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			System.out.println("31天");
			break;
		case 4:
		case 6:
			System.out.println("30天");
			break;
		case 2:
			System.out.println("请输入年份：");
			int year = scanner.nextInt();
			if(year % 4 == 0) {
				System.out.println("28天");
			}
			else {
				System.out.println("29天");
			
			}
			break;
			 default:
				break;
		}
	}
	
	@Test
	public void test08() {
		for(int i = 1; i <= 5; i++) {
			for(int j = 1; j <=5; j++) {
				if(j == 3) {
					break;
					
				}
				System.out.println(j);
			}
		}
	}
	
	@Test
	public void test09() {
		int[] array = new int[4];
		array[0] = 34;
		array[1] = 56;
		array[2] = 78;
		array[3] = 89;
		System.out.println(array.length);
		for(int i = 0; i <= array.length-1; i++) {
			System.out.println(array[i]);//顺序
		}
		for(int i = array.length-1; i >= 0; i--) {
			System.out.println(array[i]);//逆序
		}
	}
	@Test
	public void test10() {
		int num1 = 65; // 平时成绩
		int num2 = 400; // 四级成绩
//		boolean b1 = num1 > 60;
//		boolean b2 = num2 > 350;
//		boolean b = b1 && b2;
		boolean b = (num1 > 60) && (num2 > 350);
		System.out.println(b);

		boolean b1 = num1 > 60;
		System.out.println(b1);
		if (num1 > 60) {
			System.out.println("平均成绩大于60");
		} else {
			System.out.println("平均成绩小于60");
		}

		if ((num1 > 60) && (num2 > 350)) {
			System.out.println("能顺利毕业");
		}
	}
	@Test
	public void test88() {
		Scanner scanner = new Scanner(System.in);
		// Random().nextInt(300)   		0~299
		// Random().nextInt(300)+1      1~300
		int random = new Random().nextInt(300) + 1;
		System.out.println(random);
		// for (;;) {}
		while (true) {
			System.out.println("猜吧！");
			int num = scanner.nextInt();
			if (num > random) {
				System.out.println("太大了");
			} else if (num < random) {
				System.out.println("太小了");
			} else {
				System.out.println("猜对了");
				// 退出while循环
				break;
			}
		}
	}
	private int id;
	private String name;
	private int age;
	private double salary;
	public void teach()
	{
		System.out.println(name + "正在上课");
	}
}
	

